package com.example.webflux_mongo.router;

import com.example.webflux_mongo.handler.HelloWorldHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

/**
 * Copyright(C), 2020-2021, AmbroseCdMeng
 * FileName:    Router
 * Author:      AmbroseCdMeng
 * Date:        2021/1/1519:30
 * Description: 路由类
 * History:
 * <author>     <time>      <version>       <desc>
 * 作者姓名     修改时间        版本号           描述
 */
@Configuration
public class Router {
    @Autowired
    private HelloWorldHandler helloWorldHandler;

    @Bean
    public RouterFunction<ServerResponse> getString(){
        return route(GET("/helloworld"), req -> helloWorldHandler.sayHelloWorld(req));
    }
}
